<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p>半径：</p>
		<input id="n1" type="text"/>
		
		<br />
		<br />
		<p>
			<input id="btn" type="button" value="周长" onclick="add()"/>
			<input id="btn1" type="button" value="面积" onclick="jia()"/>
			
		</p>
		<p id="sum"></p>
		
		<script>
			function add(){
				var num1=document.getElementById('n1');
				var sum=document.getElementById('sum');
				result=Number(num1.value)*2*3.14;
				if(isNaN(num1.value)){
					alert("第1个数字不合法，非数字型")
				}else{
					sum.innerHTML=(num1.value)+"*2"+"*π"+"="+result;
				}
			}
			
			function jia(){
				var num1=document.getElementById('n1');
				var sum=document.getElementById('sum');
				var result=num1.value*num1.value*3.14;
			if(isNaN(num1.value)){
					alert("第1个数字不合法，非数字型")
				
				}else{
		sum.innerHTML=(num1.value)+"^2"+"*π"+"="+result;
				}
			}
			
			
		</script>
		
	</body>
</html>

